#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, M = 1e6;
int T, n, a[N], ans, b[N], l, h, sum[N];
void dfs(int pos, int c){
    if(c + sum[n] - sum[pos - 1] < ans ) return;
    if(pos == n + 1){
        ans = max(ans, c);
        return;
    }
    if(h == a[pos]){
        dfs(pos + 1, c + a[pos]);
    }
    else{
        int li = h;
        h = a[pos];
        dfs(pos + 1, c);
        h= li;
    }//red
    if(l == a[pos]) dfs(pos + 1, c + a[pos]);
    else{
        int li = l;
        l= a[pos];
        dfs(pos + 1, c);
        l = li;
    }
}
int main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin >> T;
    while(T--){
        cin >> n;
        ans = 0;
        memset(b, 0, sizeof(b));
        l = h = 0;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            sum[i] = a[i] + sum[i - 1];
        }
        dfs(1, 0);
        cout << ans << endl;
    }
    return 0;
}
